package cn.niit.letuseatdemo.service.impl;

import cn.niit.letuseatdemo.entity.domain.Classify;
import cn.niit.letuseatdemo.entity.domain.Store;
import cn.niit.letuseatdemo.mapper.ClassifyMapper;
import cn.niit.letuseatdemo.service.ClassifyService;
import cn.niit.letuseatdemo.util.LoginStoreUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Description: 菜品分类实现类
 * @Author: su_fuming
 * @CreateTime： 2022/11/23 16:54
 */


/**
 * 订单Service业务层处理
 *
 * @author su_fuming
 * @date 2022-11-23
 */
@Service
public class ClassifyServiceImpl implements ClassifyService
{
    @Autowired
    private ClassifyMapper classifyMapper;

    /**
     * 查询订单
     *
     * @param classifyId 订单主键
     * @return 订单
     */
    @Override
    public Classify selectClassifyByClassifyId(Long classifyId)
    {
        return classifyMapper.selectClassifyByClassifyId(classifyId);
    }
    /**
     * 查询订单列表
     *
     * @param classify 订单
     * @return 订单
     */
    @Override
    public List<Classify> selectClassifyList(Classify classify)
    {
        return classifyMapper.selectClassifyList(classify);
    }
    /**
     * 新增订单
     *
     * @param classify 订单
     * @return 结果
     */
    @Override
    public int insertClassify(Classify classify) {
        /** 为delFlag 赋予默认值*/
        classify.setDelFlag(0);
        /** 获取用户信息，为department 赋值，创建人信息（id,姓名)，创建时间 */
        Store loginStore = LoginStoreUtil.getLoginStore();
        classify.setCreateUserId(loginStore.getStoreId());
        classify.setCreateUserName(loginStore.getStoreName());
        classify.setGmtCreate(new Date());
        return classifyMapper.insertClassify(classify);
    }

    /**
     * 修改订单
     *
     * @param classify 订单
     * @return 结果
     */
    @Override
    public int updateClassify(Classify classify)
    {
        Store loginStore = LoginStoreUtil.getLoginStore();
        classify.setUpdateUserId(loginStore.getStoreId());
        classify.setUpdateUserName(loginStore.getStoreName());
        classify.setGmtUpdate(new Date());
        return classifyMapper.updateClassify(classify);
    }

    /**
     * 批量删除订单
     *
     * @param classifyIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteClassifyByClassifyIds(String classifyIds)
    {
        return 0;
    }

    /**
     * 删除订单信息
     *
     * @param classifyId 订单主键
     * @return 结果
     */
    @Override
    public int deleteClassifyByClassifyId(Long classifyId)
    {
        return classifyMapper.deleteClassifyByClassifyId(classifyId);
    }

    /**
     * @Description: 根据店铺ID查询菜品类别
     * @Author: Mr Yang
     * @CreateTime: 2022/12/8 17:42
     * @param: storeId
     * @return: java.util.List<cn.niit.letuseatdemo.entity.domain.Classify>
     */
    @Override
    public List<Classify> getClassifyByStoreId(Long storeId) {
        return classifyMapper.selectGoodsClassifyByStoreId(storeId);
    }
}

